<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>回购异常界面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 60px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
            
            	<div class="fieldBox ">
	                <div class="label">创建时间</div>
	                <div class="field">
	                	<input name="crtTmStart" id="crtTmStart" type="text" class="ui-datepicker" value="" ligerui="width: 115">
	                	至：
	                	<input name="crtTmEnd" id="crtTmEnd" type="text" class="ui-datepicker" value="" ligerui="width: 115">
	                </div>
	            </div>
	            <div class="fieldBox">
                    <div class="label">合同号</div>
                    <div class="field">
                        <input name="crCntNo" id="crCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">资方</div>
                    <div class="field">
                        <select name="loanId" id="loanId">
	                     <option selected="selected" value="">--全部--</option>
	                        <c:forEach items="${channelList }" var="ct">
	                        	<option value="${ct.id }">${ct.loanName }</option>
	                        </c:forEach>
                    	</select>
                    </div>
                </div>
                
                <div class="fieldBox ">
	                <div class="label">修改时间</div>
	                <div class="field">
	                	<input name="mdfTmStart" id="mdfTmStart" type="text" class="ui-datepicker" value="" ligerui="width: 115">
	                	至：
	                	<input name="mdfTmEnd" id="mdfTmEnd" type="text" class="ui-datepicker" value="" ligerui="width: 115">
	                </div>
	            </div>
	            
	            <div class="fieldBox">
                    <div class="label">回购状态</div>
                    <div class="field">
                        <select name="repSts" id="repSts">
                         	<option value="">全部</option>
                            <option value="02">回购成功</option>
                            <option value="03">回购失败</option>
                        </select>
                    </div>
                </div>
                
    			<input name="batchNo" id="batchNo" type="hidden" value="${batchNo}">
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, callback = null ;
    var batchNo = $("#batchNo").val();
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/mcr/mcrBillBuyBackRecord/mcrBuyBackFail.do?batchNo='+batchNo,
            method: 'get',
            columns: [
            	{display: '订单号', name: 'billId', minWidth: 60, align: 'center', enabledSort: false},
            	{display: '合同号', name: 'crCntNo', minWidth: 60, align: 'center', enabledSort: false},
            	{display: '客户姓名', name: 'cstNm', minWidth: 60, align: 'center', enabledSort: false},
            	{display: '放款时间',  name: 'crDt', minWidth: 100, align: 'center', enabledSort: false,render:renderDate },
            	{display: '创建时间',  name: 'crtTm', minWidth: 100, align: 'center', enabledSort: false,render:renderDate },
            	{display: '回购状态', name: 'repSts', minWidth: 100, align: 'center',  
            		render:function(rowData){
                    if(rowData.repSts=="02"){
                    	return "成功";
                     }else if(rowData.repSts=="03"){
                        return "失败";
                     }
                 }
            	},
            	{display: '操作人', name: 'userName', minWidth: 100, align: 'center', },
            	{display: '修改时间', name: 'mdfTm', minWidth: 100, align: 'center', enabledSort: false,render:renderDate },
            	{display: '操作', name: 'crtUser', minWidth: 100, align: 'center', 
                    render: function (rowdata, index, value) {
                    	var h = "";
                    	if(rowdata.repSts=="03"){
                    		h = '<a href="javascript:modifyRecord(';
                            h += "'" + rowdata.billId + "'";
                            h += ')">修改</a>';
                    	}
                    	return h;
                   }
            	},
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);
        grid.toggleCol('billId', false);

        $("#searchBar").ligerForm();
        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

    });

    //修改
    function modifyRecord(billId){
    	 $.ligerDialog.open({
	            width: 1200,
	            height: 500,
	            title: '明细',
	            url: '<%=path%>/mcr/mcrBillBuyBackRecord/mcrBuyBackFailDetailPage.do?billId='+billId
	        });
    }
    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
    
</script>

</body>
</html>
